var t = require;
var e = module;
var o = exports;
var a,
    i =
        (this && this.__extends) ||
        ((a = function (t, e) {
            return (a =
                Object.setPrototypeOf ||
                ({__proto__: []} instanceof Array &&
                    function (t, e) {
                        t.__proto__ = e;
                    }) ||
                function (t, e) {
                    for (var o in e) Object.prototype.hasOwnProperty.call(e, o) && (t[o] = e[o]);
                })(t, e);
        }),
        function (t, e) {
            a(t, e);
            function o() {
                this.constructor = t;
            }
            t.prototype = null === e ? Object.create(e) : ((o.prototype = e.prototype), new o());
        }),
    n =
        (this && this.__decorate) ||
        function (t, e, o, a) {
            var i,
                n = arguments.length,
                r = n < 3 ? e : null === a ? (a = Object.getOwnPropertyDescriptor(e, o)) : a;
            if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(t, e, o, a);
            else
                for (var s = t.length - 1; s >= 0; s--)
                    (i = t[s]) && (r = (n < 3 ? i(r) : n > 3 ? i(e, o, r) : i(e, o)) || r);
            return n > 3 && r && Object.defineProperty(e, o, r), r;
        };
Object.defineProperty(o, "__esModule", {value: !0});
var r = t("GameEm"),
    s = cc._decorator,
    c = s.ccclass,
    p =
        (s.property,
        s.menu,
        (function (t) {
            i(e, t);
            function e() {
                var e = (null !== t && t.apply(this, arguments)) || this;
                e.checkCost = 0;
                e.parseKey = "";
                e.addValue = 0;
                e.propKind = r.RewardResKind.zhuanShi;
                e.spriteIcon = "";
                e.cost1 = 0;
                e.cost2 = 0;
                e.curAddValueAddCost = 0;
                e.lastIndex = -1;
                return e;
            }
            e.prototype.uplevelItem = function (t, e) {
                var o = t[0].products,
                    a = t[1].products;
                this.spriteIcon = e;
                var i = o.split("_"),
                    n = a.split("_")[1],
                    r = i[1];
                this.cost1 = parseInt(r);
                this.cost2 = parseInt(n);
                this._toMaxLab.$Label.string = "" + n;
                this._countCenterLab.$Label.string = "" + r;
                this._countFillLab.$Label.string = "" + n;
                var s = PayData.getProZsCount(),
                    c = t[0].cash;
                s >= 700 && (c = t[1].cash);
                this._costLab1.$Label.string = "￥" + c;
                this.checkCost = c;
                this.updateCurPig();
            };
            e.prototype.clickPay = function () {
                var t = this,
                    e = PayData.getProZsCount();
                if (!(e < this.cost1))
                    if (PayData.checkPayCost(this.checkCost)) {
                        if (e >= this.cost2) {
                            this.addValue = this.cost2;
                            this.parseKey = "20032";
                        } else {
                            this.addValue = this.cost1;
                            this.parseKey = "20031";
                        }
                        var o = this._costLab1.convertToWorldSpaceAR(cc.Vec2.ZERO),
                            a = cc.v2(o).add(cc.v2(-300, 700));
                        PayData.addPayData(
                            this.parseKey,
                            this.checkCost,
                            function (e) {
                                if (e) {
                                    PayData.addPropZs(-t.addValue);
                                    t.addValue == t.cost2 ? QReport.send("220031") : QReport.send("220032");
                                    QReport.send("220021");
                                    var i = {
                                        resId: t.parseKey,
                                        count: t.addValue,
                                        type: 2,
                                        rewadJson: {},
                                        tip: "猪猪银行",
                                        tip2: "价格数量" + t.addValue
                                    };
                                    PayData.addPropData(t.propKind, t.addValue, o);
                                    EVUIEffView.emit(
                                        EVUIEffView.movePropSpriteIcon,
                                        o,
                                        a,
                                        t.spriteIcon,
                                        !1,
                                        "" + t.addValue
                                    );
                                    t.updateCurPig();
                                    PayData.addLog(i.resId, i.count, i.type, [{id: 1, num: t.addValue}], i.tip, i.tip2);
                                    t.playPigAnimal(2);
                                    t.scheduleOnce(function () {
                                        t.playPigAnimal(0);
                                    }, 0.3);
                                }
                            },
                            [{id: 1, num: this.addValue, pid: this.parseKey}]
                        );
                    } else console.log("ShopGroupItem01 ----------------- 价格不够");
            };
            e.prototype.updateCurPig = function () {
                var t = PayData.getProZsCount();
                t = Math.min(t, 700);
                this._toMaxLab.$Label.string = t + "";
                this._progress.$ProgressBar.progress = t / 700;
                if (t >= 700) {
                    this.playPigAnimal(1);
                    this._tipFill.$Label.string = "小猪存钱罐收集满啦";
                } else {
                    this.playPigAnimal(0);
                    this._tipFill.$Label.string = "升级以填充小猪存钱罐中的宝石！";
                }
                this.setRender(this._costLab1.parent.parent, t >= this.cost1);
            };
            e.prototype.setRender = function (t, e) {
                for (var o = t.getComponentsInChildren(cc.RenderComponent), a = 0; a < o.length; a++)
                    CacheDataManager.setSpriteMat(o[a], e);
            };
            e.prototype.playPigAnimal = function (t) {
                if (this._pig && this.lastIndex != t) {
                    this.lastIndex = t;
                    var e = this._pig.$Animation;
                    e.stop();
                    switch (t) {
                        case 0:
                            e.play("piganimal");
                            break;
                        case 1:
                            e.play("pigcoin");
                            break;
                        case 2:
                            e.play("pigjump");
                    }
                }
            };
            return n([c], e);
        })(Thor));
o.default = p;
